public class test2 {
    public static void main(String[] args) {
        //算术运算符
        System.out.println(5/2);
        System.out.println((float) 5/2);
        System.out.println(5/(float)2);
        System.out.println((float) (5/2));
        System.out.println(10%3);
        System.out.println(10%-3);
        System.out.println(-10%3);
        System.out.println(-10%-3);
        long b = 10;
        int c = 5;
        //c =b+c;//error,b+c为long类型
        c += b;//特点：会帮我们进行类型的转换
        System.out.println(c);
        System.out.println(b==c);//=是赋值，==是相等
        System.out.println(b!=c);
        System.out.println(b>=c);
        System.out.println(b<=c);
        System.out.println(b>c);
        System.out.println(b<c);
        System.out.println(b==10&&c==5);
        System.out.println(b==10&&c==15);
        System.out.println(b==10||c==2);
        System.out.println(b==3||c==2);
        System.out.println(b==2||c==15);
        int a = 1;
        System.out.println(!(a==1));
        System.out.println(!(a==2));
        int i = 10;
        int o = 6;
        int max = i>o ? i:o;//输出最大值，需要返回值接收
        System.out.println(max);

    }
    public static void main7(String[] args) {
        String s1 = "冼泽厚";//字符串类型
        String s2 = "人机";
        System.out.println(s1+s2);
        //调用String类型的库方法，将a变为字符串
        int a = 100;
        String S1 = String.valueOf(a);
        System.out.println(S1);
        String S2 = a + s1 + "666";//此时的加号为拼接的意思
        System.out.println(S2);
        String s3 = 10 + 20+ "x";
        String s4 = "x" + 10 +20;
        System.out.println(s3);//30x
        System.out.println(s4);//x1020
        String str3 = "10000";
        //调用Interger方法实现字符串到整数的转换
        int ret = Integer.valueOf(str3+1);
        System.out.println(ret);
        int ret2 = Integer.parseInt(str3+2);
        System.out.println(ret2);

    }
    public static void main6(String[] args) {
        int a = 10;
        long b = 20;
        int c = (int)(a+b);//右边类型被提升为long类型,需要强制类型转换
        //小于4个字节的内容会提升为int进行计算
        byte b1 =125;
        byte b2 = 17;
        int b3 = b1 + b2;
    }
    public static void main5(String[] args) {
        int a = 10;
        long b = 100L;
        //a = b;  //error,不能把8个字节赋值给4个字节
        a = (int)b;//强制类型转换
        //隐式类型转换，把a转换为long类型
        b = a;
        boolean c = true;
        //a = (int) c;
        //c = a;//boolean类型无法与其他类型转换
    }
    public static void main4(String[] args) {
        //java中真假只有true和false 不能和任何类型转换
        //没有明确规定占几个字节
        boolean w = true;
        System.out.println(w);
    }
    public static void main3(String[] args) {
        //没有负数的
        //字符型变量       2个字节
        char ch = 'a';
        System.out.println(ch);
        char ch2 = '谢';
        System.out.println(ch2);    //包装类    Character
    }
    public static void main2(String[] args) {
        //整形        4个字节  2^31-1~2^31
        int x = 40;
        //长整型      8个字节  2^63-1~-2^63
        long b = 10L;
        //短整型      2个字节  2^15-1~-2^15
        short a = 20;
        //字节型      1个字节  2^7-1~-2^7
        byte i = 30;
        System.out.println(b);
        System.out.println(Long.MAX_VALUE);
        System.out.println(Long.MIN_VALUE);
        System.out.println(a);
        System.out.println(Short.MAX_VALUE);
        System.out.println(Short.MIN_VALUE);
        System.out.println(i);
        System.out.println(Byte.MAX_VALUE);
        System.out.println(Byte.MIN_VALUE);
        //双精度浮点型 8个字节
        double d = 3.14;
        System.out.println(d);
        System.out.println(Double.MAX_VALUE);
        //输出的是浮点数最小的一个非负整数
        System.out.println(Double.MIN_VALUE);
        //0
        System.out.println(i/x);
        //单精度浮点类型  4个字节
        float g = 12.5f;
        System.out.println(g);
    }
}
